package com.rjt.video.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rjt.video.model.VideoModel;
import com.rjt.video.service.impl.DouyinServiceImpl;
import com.rjt.video.service.impl.HuoShanServiceImpl;
import com.rjt.video.service.impl.KuaiShouServiceImpl;
import com.rjt.video.service.impl.PiPiXServiceImpl;
import com.rjt.video.service.impl.WeiShiServiceImpl;
import com.rjt.video.service.impl.ZuiYouServiceImpl;

/**  
* @comment
* @author renjiangtao 
* @date 2019年6月14日  
* @version 1.0  
*/
@RestController
@RequestMapping("video")
public class VideoController {
	
	@Autowired
	private WeiShiServiceImpl weiShiServiceImpl;

	@Autowired
	private DouyinServiceImpl douyinServiceImpl;

	@Autowired
	private PiPiXServiceImpl piPiXServiceImpl;

	@Autowired
	private ZuiYouServiceImpl zuiYouServiceImpl;

	@Autowired
	private HuoShanServiceImpl huoShanServiceImpl;

	@Autowired
	private KuaiShouServiceImpl kuaiShouServiceImpl;
	
	
	 @GetMapping("parse")
	   public VideoModel parse(String url) {
		   if (url.indexOf("weishi.qq.com")!= -1 ) {
			    return  weiShiServiceImpl.parseUrl(url);
			} else if (url.indexOf("douyin.com") != -1 || url.indexOf("iesdouyin.com") != -1) {
			    return  douyinServiceImpl.parseUrl(url);
			} else if ( url.indexOf("pipix.com") != -1) {
			    return  piPiXServiceImpl.parseUrl(url);
			} else if ( url.indexOf("izuiyou.com") != -1) {
				return  zuiYouServiceImpl.parseUrl(url);
			} else if ( url.indexOf("huoshan.com") != -1) {
				return  huoShanServiceImpl.parseUrl(url);
			} else if ( url.indexOf("kuaishou.com") != -1 || url.indexOf("gifshow.com") != -1 || url.indexOf("chenzhongtech.com") != -1) {
				return  kuaiShouServiceImpl.parseUrl(url);
			} else {
				return null;
			}
	   }
}
